<?
	
	function get_fils($path, $filter)
	{
		$out="";
		$filearr=array();
		$d = dir('./'.$path) or die($php_errormsg);

        while (false !== ($f = $d->read()))
		{ 
			if($f != "." && $f != ".." && !in_array($f,$filearr))
			{
				if (is_file('./'.$path.'/'.$f))
				{
					array_push($filearr,$f);

                    $flen=strlen($f);
					$ext=substr($f,$flen-3,3);
					if($ext == $filter)
					{
						if($out == "")
							$out=$path.'/'.$f;
						else
							$out.=":".$path.'/'.$f;
					}
				}
				else if(is_dir('./'.$path.'/'.$f))
				{
					if($out == "")
						$out=get_fils($path.'/'.$f, $filter);
					else
						$out.=":".get_fils($path.'/'.$f, $filter);
				}
			}
		}
		$d->close();
		return $out;
	}
	$fileFilter = $_GET["filter"];
	$targetDir = $_GET["target"];
    chdir($targetDir);
	$targetList=get_fils("", $fileFilter);
	echo $targetList;	
?>
